<template>
  <div>
      <el-table
    :data="tableData"
    stripe
    border
    style="width: 100%">
    <el-table-column
      prop="work_num"
      label="编号"
      align="center"
      width="180">
    </el-table-column>
    <el-table-column
      prop="task_start"
      label="计划开始时间"
      align="center"
      width="180">
    </el-table-column>
    <el-table-column
      prop="task_level"
      align="center"
      label="级别">
        <template slot-scope="scope">
  
           <el-tag v-if="scope.row.task_level=='一般'">{{ scope.row.task_level }}</el-tag>
            <el-tag v-if="scope.row.task_level=='重要'" type="success">{{ scope.row.task_level }}</el-tag>
            <el-tag v-if="scope.row.task_level=='紧急'" type="danger">{{ scope.row.task_level }}</el-tag>


      </template>
    </el-table-column>
      <el-table-column
      prop="status_name"
      align="center"
      label="状态">
    </el-table-column>
      <el-table-column
      prop="task_type_string"
      align="center"
      label="类型">
    </el-table-column>
      <el-table-column
      prop="user_name"
      align="center"
      label="执行班组/人">
    </el-table-column>
        <el-table-column align="center" label="详情">
      <template slot-scope="scope">
        <el-button
        type="primary"

          size="mini"
          icon="el-icon-zoom-in"
          @click="handleEdit(scope.$index, scope.row)"></el-button>

      </template>
    </el-table-column>
  </el-table>
    <!-- 详情弹框 -->
    <el-dialog v-dialogDrag :title="detailTitle" center :visible.sync="dialogTableVisible1" width="30%">
      <div slot="title" class="header-title">
        <i class="el-icon-edit" />
        <span class="seeTit">{{ detailTitle }}</span>
      </div>
      <div>
        <Detail :det-staus="detStaus" :accids="accids" :details-num="detailsNum" />
      </div>
    </el-dialog>
    <el-pagination
     class="fix"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="PageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="totals">
    </el-pagination>
  </div>
</template>
<script>
  import {todo} from '@/api/todo'
import Detail from './detail.vue'
export default {
  components:{ Detail  },
  data(){
    return{
      tableData:[
        {
          date:'299',
          name:'hsh',
          address:'haha'
        }
      ],
      currentPage:1,
      totals:10,
      PageSize:10,
      detailTitle:'详情',
      dialogTableVisible1:false,
      accids:'',
      detStaus:'',// 传给子组件状态值
      detailsNum:'',// 详情组件里，区分抢修报修与巡检试验
    }
  },
  created(){
    this.getList()
  },
  methods:{
        handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
         this.PageSize=val
        this.getList()
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
        this.currentPage=val
        this.getList()
      },
       // 详情
    handleEdit(a, b) {
      this.dialogTableVisible1 = true
      this.accids = b.id
       this.detStaus = b.task_type_string
      if (b.task_type == '抢修' || b.task_type == '报修') {
        this.detailsNum = 1
      } else {
        this.detailsNum = 2
      }
    },
    detailClose(a) {
      this.dialogTableVisible1 = a
    },
    getList(){
      let data={}
      data.limit=this.PageSize
      data.offset=this.currentPage
      todo(data).then(res=>{
        this.totals=res.data.total
        this.tableData=res.data.list
      })

    }
  }
}
</script>
<style lang="scss" scoped>
  .fix{
    position: fixed;
    bottom: 20px;
    right: 20px;
  }
  .header-title{
    .seeTit{
      padding-left: 10px;
    }
  }
  ::v-deep.el-dialog__header{
    background-color: #263445;
    color: #fff;
  }
  .dialog-footer{
        text-align: right;

  }
  ::v-deep.el-dialog__footer{
    text-align: right;
  }
</style>
